// component/fliter/filter.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
		
  },

  /**
   * 组件的初始数据
   */
  data: {
    selectData:[],
    showGroup:false,
    showContent:false,
    showShadow:false,
    showSuccess:false,
    isFixed:true,
    list:[],
	single:false,
    selectAll:[],
    color:'#097c25'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    closeBtn:function(){
      this.setData({
        showShadow:false,
        showGroup:false,
        showSuccess:false,
        isFixed:false
      })
      var myEventDetail = {} // detail对象，提供给事件监听函数
      var myEventOption = {} // 触发事件的选项
      this.triggerEvent('close', {})
    },
    selectBtn:function(e){
      let selectData = this.data.selectData

    if (selectData[e.currentTarget.dataset.index] === true) {
      console.log(11)
      selectData[e.currentTarget.dataset.index] = false
    } else {   
		if(this.data.single==true){
				selectData=[]  
		}
      selectData[e.currentTarget.dataset.index] = true
	
    }
    console.log(selectData)
    this.setData({
    selectData:selectData
    })
    },
    //
    quanxuan:function(e){
      let selectData = this.data.selectData
        console.log(e)
        let selectAll=this.data.selectAll
      if (selectAll[e.currentTarget.dataset.index] === true){
        selectAll[e.currentTarget.dataset.index] = false
        for (let i = 0; i < this.data.list[e.currentTarget.dataset.index].children.length; i++) {
          console.log(this.data.list[e.currentTarget.dataset.index].children[i].id)
          selectData[this.data.list[e.currentTarget.dataset.index].children[i].id] = false
        }
      }else{
        selectAll[e.currentTarget.dataset.index] = true
        console.log(this.data.list[e.currentTarget.dataset.index].children)
        for (let i = 0; i < this.data.list[e.currentTarget.dataset.index].children.length; i++) {
          console.log(this.data.list[e.currentTarget.dataset.index].children[i].id)
          selectData[this.data.list[e.currentTarget.dataset.index].children[i].id] = true
        }
      }
    
      console.log(selectData)
      this.setData({
        selectAll:selectAll,
        selectData:selectData
        })
    },

    submitBtn:function(e){
      let select=[]
      for (let i = 0; i < this.data.selectData.length;i++){
        if(this.data.selectData[i]==true){
            select.push(i)
        }
      }
      this.setData({
        showGroup: false,
        showContent: false,
        showShadow: false,
        showSuccess: false,
      })
    
      this.triggerEvent('submit', select)
    }

  },


   
})
